<template>
    <div class="contentDiv">
        <Spin size="large" fix v-if="Loading"></Spin>
        <Form :label-width="180" :disabled="true">
            <Row style="margin-top: 15px">
                <i-col span="24" class="title">
                    <Form-item :label-width="10">
                        打印信息&打印记录
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="24">
                    <vxe-table border
                               auto-resize
                               row-id="id"
                               :row-key="true"
                               show-overflow="tooltip"
                               highlight-hover-row
                               align="center"
                               header-align="center"
                               ref="xTree"
                               :data="ss21005DtoList">
                        <vxe-table-column field="dbze0002" title="月份" align="center"/>
                        <vxe-table-column field="dbze0003" title="领取日期" align="center" :formatter="renderTime"/>
                        <vxe-table-column field="dbze0004" title="金额" align="center"/>
                        <vxe-table-column field="dbze0101" title="打印状态" align="center" :formatter="printStatus"/>
                        <vxe-table-column field="dbze0102" title="打印时间" align="center" :formatter="renderTime"/>
                        <vxe-table-column field="dbze0103" title="打印人" align="center"/>
                    </vxe-table>
                </i-col>
            </Row>
            <Row style="margin-top: 15px">
                <i-col span="24" class="title">
                    <Form-item :label-width="10">
                        打印操作
                    </Form-item>
                </i-col>
            </Row>
        </Form>
        <Form :label-width="180">
            <Row>
                <i-col span="12">
                    <Form-item label="年度:">
                        <DatePicker type="year" v-model="year" :value="year" @on-change="changeYear"  :editable="false"></DatePicker>
                    </Form-item>
                </i-col>
                <i-col span="12">
                    <Form-item label="打印页面:">
                        <Select v-model="leftOrRight" style="width: 200px">
                            <Option value="0">左侧页面</Option>
                            <Option value="1">右侧页面</Option>
                        </Select>
                    </Form-item>
                </i-col>
            </Row>
        </Form>
        <Row>
            <i-col span="24" class="title">
                <Button type="primary" @click="print" :disabled="!canPrint">打印</Button>
            </i-col>
        </Row>
    </div>
</template>

<script>
    import {postAction} from '@/api/request'
    import ICol from "view-design/src/components/grid/col";
    import {CommonMixin} from '@/views/common/js/CommonMixin'
    import {LodopMixin} from '../lodop'

    export default {
        mixins: [CommonMixin, LodopMixin],
        components: {ICol},
        props: ['ss21005DtoList', 'lodopGetRecord', 'dbzb0100', 'dbza0015'],
        data() {
            return {
                modal1: false,
                visible: false,
                disableSubmit: false,
                title: "",
                model: {},
                canPrint: false,
                leftOrRight: "0",
                year: "",
                url: "/api/ac/subsistence/lodopServiceImpl/changeYear",
            }
        },
        methods: {
            print() {
                var param = new Object();
                param.lodopGetRecord = this.lodopGetRecord;
                param.dbzp0001 = this.dbza0015;
                param.dbzp0002 = "PTN_4";
                param.dbzp0005 = this.leftOrRight;
                this.commonPrint(param, 4, null, this.dbzb0100);
            },
            changeYear(e) {
                this.Loading = true;
                var param = new Object();
                param.year = e;
                param.dbzb0100 = this.dbzb0100;
                postAction(this.url, param).then((res) => {
                    if (res.data.errcode != 0) {
                        this.$Message.error(res.data.errmsg);
                    } else {
                        this.lodopGetRecord = res.data.data.lodopGetRecord;
                        this.ss21005DtoList = res.data.data.ss21005DtoList;
                        this.setPrint();
                    }
                }).finally(() => {
                    this.Loading = false;
                })
            },
            setPrint() {
                this.canPrint = false;
                var ss21005DtoList = this.ss21005DtoList;
                for (var i in ss21005DtoList) {
                    var dbze0101 = ss21005DtoList[i].dbze0101;
                    if (dbze0101 == "0") {
                        this.canPrint = true;
                        break;
                    }
                }
            }

        },
        mounted() {
            var date = new Date();
            this.year = this.DateFormat(date, 'YYYY');
            this.setPrint();
        }
    }
</script>

<style scoped>
    /deep/ .title {
        height: 50px;
        text-align: center;
        line-height: 50px;
    }
</style>